From 80e972a99b4fd78eb3f597638bfa799b548c174c Mon Sep 17 00:00:00 2001
From: Fuwn <contact@fuwn.me>
Date: Mon, 12 Feb 2024 12:34:45 -0800
Subject: fix(time): proper database time update

---
 src/routes/user/[user]/badges/+page.svelte | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

(limited to 'src/routes/user/[user]/badges/+page.svelte')

diff --git a/src/routes/user/[user]/badges/+page.svelte b/src/routes/user/[user]/badges/+page.svelte
index 1e22a489..e0cbeeb8 100644
--- a/src/routes/user/[user]/badges/+page.svelte
+++ b/src/routes/user/[user]/badges/+page.svelte
@@ -5,7 +5,7 @@
 	// import { domToBlob } from 'modern-screenshot';
 	import { onMount } from 'svelte';
 	import HeadTitle from '$lib/Home/HeadTitle.svelte';
-	import { databaseTimeToDate, dateToDatabaseTime } from '$lib/Utility/time';
+	import { databaseTimeToDate, dateToInputTime, inputTimeToDatabaseTime } from '$lib/Utility/time';
 	import root from '$lib/Utility/root.js';
 	import tooltip from '$lib/Tooltip/tooltip.js';
 	import proxy from '$lib/Utility/proxy.js';
@@ -191,7 +191,9 @@
 			)}${
 				description.value.length > 0 ? `&description=${encodeURIComponent(description.value)}` : ''
 			}${category.value.length > 0 ? `&category=${encodeURIComponent(category.value)}` : ''}${
-				time.valueAsDate ? `&time=${encodeURIComponent(dateToDatabaseTime(time.valueAsDate))}` : ''
+				time.valueAsDate
+					? `&time=${encodeURIComponent(inputTimeToDatabaseTime(time.valueAsDate))}`
+					: ''
 			}${
 				selectedBadge && selectedBadge.id ? `&update=${encodeURIComponent(selectedBadge.id)}` : ''
 			}`,
@@ -564,7 +566,9 @@
 										<span style="float: right;">
 											<input
 												type="datetime-local"
-												value={selectedBadge && selectedBadge.time ? selectedBadge.time : ''}
+												value={selectedBadge && selectedBadge.time
+													? dateToInputTime(databaseTimeToDate(selectedBadge.time))
+													: ''}
 											/>
 											<small>Must be full date and time, defaults to now if any fields empty</small>
 										</span>
-- 
cgit v1.2.3

